<?php

class MinPriceObjBehavior extends CActiveRecordBehavior {

	/**
	 * 搜索模型名称
	 * Enter description here ...
	 * @var unknown_type
	 */
	public $modelName = '';
	/**
	 * 关联字段
	 * Enter description here ...
	 * @var unknown_type
	 */
	public $relatedAttr = '';
	
	/**
	 * 返回商品(Goods)对象
	 * Enter description here ...
	 */
	public function getMinObj() {
		$owner = $this->owner;
		$model = new $this->modelName;
		$criteria = new CDbCriteria();
		$criteria->scopes = array('listing');
		$criteria->with = array(
			'profile' => array(
				'with' => 'company'
			),
			'priceInfo'
		);
		$criteria->compare($this->relatedAttr, $owner->id);
		$criteria->order = "price_dealer asc";
		return $model->find($criteria);
	}
}

?>